package com.cizzy.user.controller;

import com.cizzy.user.common.Result;
import com.cizzy.user.entity.UserCount;
import com.cizzy.user.service.IUserCountService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author crissy-月下闲人
 * @since 2023-10-29
 */
@RestController
@CrossOrigin
@RequestMapping("/userCount")
public class UserCountController {
    @Resource
    private IUserCountService userCountService;

    @ResponseBody
    @GetMapping("/getUserCountById")
    public Result<UserCount> getUserCountById(@RequestParam("id") Long id) {
        return userCountService.getUserCountByUserId(id);
    }

    @ResponseBody
    @PostMapping("/getUserCountListByIds")
    public Result<List<UserCount>> getUserCountListByIds(@RequestBody List<Long> ids) {
        return userCountService.getUserCountListByUserIds(ids);
    }

    @ResponseBody
    @PostMapping("/addUserCountById")
    public Result<UserCount> addUserCountById(@RequestParam("column") String column, @RequestParam("id") Long id, @RequestParam("count") Integer count) {
        return userCountService.addUserCountById(column, id, count);
    }
}
